<%@ page language="java" contentType="text/html; charset=utf-8"
	pageEncoding="utf-8" isELIgnored="false"%>
<%@ include file="/WEB-INF/views/shared/taglib.jsp"%>
<%
	request.setAttribute("title", "邀请码");
%>
<%@ include file="/WEB-INF/views/shared/master/weContentHeader.jsp"%>
<style type="text/css">

</style>
<input type="hidden" value="${qrCustomer.linkname}" id="refLinkname" />
<div style="text-align:center;">
	<img src="<c:url value='/wechat/cust/invitation/qrCode?logo=0&content=${qrUrl}&picPath=longpicture.jpg&position=middle'/>" style="width:100%;"/>
</div>


<%@ include file="/WEB-INF/views/shared/scripts/jquery.jsp"%>
<script type="text/javascript" src="http://res.wx.qq.com/open/js/jweixin-1.2.0.js"></script>
<script type="text/javascript">
$(function(){
	var shareCode = $.getUrlParam('shareCode');
	var userIdentity="${userIdentity}";
	
	var url=$.getVirtualPath()+"/wechat/cust/personCenter/shareSignature";
	var linkHref=location.href.split('#')[0];
	
	var href=encodeURIComponent(linkHref);
	var shareCodeParam=$.isNull(shareCode)?"":"&shareCode="+shareCode;
	var resultJson=$.getJsonPost(url,"href="+href+shareCodeParam);
	
	var username=$("#refLinkname").val();
	
	if($.isNull(shareCode)){
		linkHref=linkHref.appendUrlParam("shareCode="+userIdentity);
	}
	if(!$.isNull(username)){
		username = resultJson.customer.linkname;
	}
	
	var config={
			debug: false,
		  	appId: resultJson.jsapiSignature.appId,// 公众号的唯一标识
		  	timestamp: resultJson.jsapiSignature.timestamp,// 生成签名的时间戳
		  	nonceStr: resultJson.jsapiSignature.nonceStr,// 生成签名的随机串
		  	signature: resultJson.jsapiSignature.signature,// 签名
		  	jsApiList: ['onMenuShareAppMessage','onMenuShareTimeline']
		}
	
	wx.config(config);
	
	// 微信事件
	wx.ready(function () {
		
		// 分享朋友
		wx.onMenuShareAppMessage({
		    title: username+'的邀请码',
		    desc:  username+'邀请您加入普天永利，开启创富之旅。',
		    link: linkHref,
		    imgUrl: 'http://www.putiyoli.net/ares/images/logo.png',
		    success: function () {
				console.log(arguments);
		    },error:function(){
		    }
		});
		
		wx.onMenuShareTimeline({
			title: username+'邀请您加入普天永利，开启创富之旅。',
		    link: linkHref,
		    imgUrl: 'http://www.putiyoli.net/ares/images/logo.png',
			success: function (res) {
			}
		});

		// 微信错误处理机制
		wx.error(function (res) {
			console.log(res.errMsg);
		});
		
	});
	
});

</script>

<%@ include file="/WEB-INF/views/shared/master/weContentFooter.jsp"%>
